/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dinner.web.money;

import java.util.List;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import dinner.web.secure.AutorisingSystem;
import dinner.web.secure.UnAutorizationException;

/**
 * 
 * @author Bizon
 */
@WebService()
public class MoneyService {

	/**
	 * Web service operation
	 */
	@WebMethod(operationName = "getMoney")
	public Double getMoney(@WebParam(name = "id") long id) throws UnAutorizationException {
		return MoneyUtilsDB.getDb().getCurrentBalance(AutorisingSystem.isLogined(id));
	}

	/**
	 * Web service operation
	 */
	@WebMethod(operationName = "putMoney")
	public void putMoney(@WebParam(name = "id") long id, @WebParam(name = "summ") double summ, @WebParam(name = "userName") String userName)
			throws UnAutorizationException {
		AutorisingSystem.checkAdmin(id);
		MoneyUtilsDB.getDb().addBalance(userName, summ);
	}

	/**
	 * Web service operation
	 */
	@WebMethod(operationName = "getTableMoney")
	public List<TableLine> getTableMoney(@WebParam(name = "id") long id) throws UnAutorizationException {
		// TODO write your implementation code here:
		return null;
	}

}
